package tech.aistar.corejava.day13;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author success
 * @version 1.0
 * @description:本类用来演示:
 * @date 2019/8/2 0002
 */
public class FileReaderDemo {
    public static void main(String[] args) {
        BufferedReader br = null;


        try {
            br = new BufferedReader(new FileReader("src/tech/aistar/corejava/day13/ObjectDemo.java"));

            while(true){
//                int len = br.read();//读取就是单个字符
//                if(len == -1)
//                    break;
//                System.out.print((char)len);

                String line = br.readLine();//读取文件中的一整行

                if(line == null)
                    break;

                System.out.println(line);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally{
            if(null!=br){
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
